package bairui.international.model.status;

/**
 *
 * (雇员状态)State_Employee
 */
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@com.lianjing.sh.model.common.annotation.Comment("雇员状态")
@com.lianjing.sh.processing.info.annotation.InfoComment("雇员状态")
public enum State_Employee implements com.sh_lianjing.state.Statable, com.sh_lianjing.standard.EnumCommentable<State_Employee> {

	/**
	 * <b>状态:</b> </br>
	 * (在职)Working</br>
	 */
	@com.lianjing.sh.model.common.annotation.Comment("在职")
	@com.lianjing.sh.processing.info.annotation.InfoComment("在职")
	Working("在职")
,
	/**
	 * <b>状态:</b> </br>
	 * (离职)Dimission</br>
	 */
	@com.lianjing.sh.model.common.annotation.Comment("离职")
	@com.lianjing.sh.processing.info.annotation.InfoComment("离职")
	Dimission("离职")
;

	private static java.util.Map<String, State_Employee> Cache = new java.util.HashMap<>();
	static{
		for(State_Employee enumItem : State_Employee.values()){
			Cache.put(enumItem.getComment(), enumItem);
		}
	}

	private String comment;

	private State_Employee(String comment){
		this.comment = comment;
	}

	@Override
	public String toString() {
		return comment;
	}

	@Override
	public String getComment() {
		return comment;
	}

	/**
	 * 通过备注解析状态相关
	 */
	@Override
	public State_Employee parseByComment(String comment) {
		return State_Employee.parse(comment);
	}

	public static State_Employee parse(String comment) {
		State_Employee enumItem = Cache.get(comment);
		if(null == enumItem){
			 throw new com.sh_lianjing.standard.exception.EnumCommentableException(State_Employee.class, comment);
		}
		return enumItem;
	}

	/**
	 * from 转换方法相关
	 */
	/** <b>(在职状态)</b> */
	public com.sh_lianjing.state.StateTransition<State_Employee> t_解聘_from_Working() throws com.sh_lianjing.state.StateConvertException {
		if(this != Working){
			throw new com.sh_lianjing.state.StateConvertException(this, Dimission);
		}
		return new com.sh_lianjing.state.StateTransition<State_Employee>("", this, Dimission);
	}

	/** <b></b> */
	public static com.sh_lianjing.state.StateTransition<State_Employee> t_聘用() {
		return new com.sh_lianjing.state.StateTransition<State_Employee>("", null, Working);
	}

	/**
	 * to 转换方法相关
	 */

	/**
	 * 验证方法相关
	 */
	public Validator validator(){
		return new Validator();
	}
	
	public class Validator {
		private com.sh_lianjing.state.validate.StateCondition<State_Employee> condition = new com.sh_lianjing.state.validate.StateCondition<>();
	
		public State_Employee end() throws com.sh_lianjing.state.StateException{
			if(!condition.validate(State_Employee.this)){
				throw new com.sh_lianjing.state.StateException("雇员状态错误，不能执行操作");
			}
			return State_Employee.this;
		}
	
		/** <b>验证[在职]状态</b> */
		public Validator v_Working() {
			this.condition.add(Working);
			return this;
		}
		/** <b>验证[离职]状态</b> */
		public Validator v_Dimission() {
			this.condition.add(Dimission);
			return this;
		}
	}

}
